package com.mixi.feedreader;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Toast;

public class Publisher extends Activity {
        
        //private Button[] btnSet;
        
        
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                // TODO Auto-generated method stub
                super.onCreate(savedInstanceState);
                this.requestWindowFeature(Window.FEATURE_NO_TITLE);
                setContentView(R.layout.publisher);
                
                
                
                
                
                
//              LinearLayout row1 = (LinearLayout) findViewById(R.id.row1);
//              LinearLayout row2 = (LinearLayout) findViewById(R.id.row2);
//              LinearLayout row3 = (LinearLayout) findViewById(R.id.row3);
                
                //for(ImageButton bx:row1.getch)
                LinearLayout pWrap = (LinearLayout) findViewById(R.id.p_wrapper);
                int cnt=1;
                
                for(int i=0;i<pWrap.getChildCount();i++){
                        LinearLayout eachRow = (LinearLayout) pWrap.getChildAt(i);
                        for(int x=0;x<eachRow.getChildCount();x++){
                                ImageButton eachBtn = (ImageButton)eachRow.getChildAt(x);
                                eachBtn.setTag(cnt++);
                                eachBtn.setOnClickListener(btnSet);
                                
                        }
                }
        
                
        }
        
        OnClickListener btnSet = new OnClickListener() {
                
                public void onClick(View v) {
                       // Toast.makeText(Publisher.this, " is "+v.getTag() , Toast.LENGTH_SHORT).show();
                        
                        Intent reply = new Intent();
                        Bundle bx = new Bundle();
                        bx.putString("code", v.getTag()+"");
                        reply.putExtras(bx);
                        setResult(RESULT_OK,reply);
                        
                        finish();
                }
        };

}